#if !defined(_SENUMTYPEDESCRIPTOR_H)
#define _SENUMTYPEDESCRIPTOR_H

#include <boost/foreach.hpp>
#include <boost/regex.hpp>

#include "TypeDescriptor.h"
#include "SEnumEntry.h"

CREATE_ALIAS( SEnumTypeDescriptor );

/**
 * Class used to store an enum type descriptor.
 */
class DECLARATION_DLL SEnumTypeDescriptor : public TypeDescriptor
{
	/** Vector of entries to define enum values */
	SEnumEntrySpVectorSp entries;

	/** SEnumTypeDescriptor constructor to create the type descriptor for a SEnum */
	SEnumTypeDescriptor(string pluginName, string name, string description) : TypeDescriptor(pluginName, name, description)
	{
		entries = SEnumEntrySpVectorSp( new SEnumEntrySpVector() );
	}

	/**
	 * Returns true if the enum key is valid.
	 * A letter or underscore + alphanumeric sequence or underscore.
	 */
	bool IsValidKey(string key);

	public:
		
  	    /**
	     * Add an enum entry.
	     */
		virtual void AddEntry(string value, unsigned long numericValue, string description);

  	    /**
	     * Delete all the enum entries
	     */
		virtual void ClearEntries()
		{
			entries->clear();
		}

  	    /**
	     * Return the number of enum entries.
	     */
		virtual int GetNumberOfEntries()
		{
			return entries->size();
		}

		/**
		 * Get the enumerator value associated with a specific key.
		 */
		virtual unsigned long GetNumericValue(string value);

		/**
		* Get the enumerator key associated with a specific value.
		*/
		virtual string GetValue(unsigned long numericValue);

		/**
		 * Get the entry in a specific position.
		 */
		virtual SEnumEntrySp GetEntry(int index);

		/**
		 * Returns true if there is a entry with a specific key.
		 */
		virtual bool IsDefined(string value);

		/**
		 * Returns true if there is a entry with a specific value.
		 */
		virtual bool IsDefined(unsigned long numericValue);

		/**
		 * Returns if the type descriptor is valid.
		 */
		virtual bool IsValid()
		{
			return GetNumberOfEntries() > 0;
		}

		/**
		 * Returns true if the type descriptor describe the type specified.
		 */
		virtual bool Describe(SType type)
		{
			return type == STypeEnum;
		}

		/**
	     * Returns the type described from this type descriptor (STypeEnum).
 		 */
		virtual SType GetDescribedType()
		{
			return STypeEnum;
		}

		/**
		 *   Factory method to create the type descriptor for a SEnum.
		 */
		static SEnumTypeDescriptorSp Create(string pluginName, string name, string description);
};

#endif  //_SENUMTYPEDESCRIPTOR_H
